package ucap.com.lesanapp.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.util.Log;

import ucap.com.lesanapp.global.SettingsModelState;

/**
 * Created by wekingwang on 16/8/5.
 * 网络环境判断
 */
public class NetworkStateUtils {

    public static int network(Context context) {
        final ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        final NetworkInfo mobNetInfoActivity = connectivityManager.getActiveNetworkInfo();
        try {
            int type = mobNetInfoActivity.getType();
            if (type == ConnectivityManager.TYPE_MOBILE) {
                return ConnectivityManager.TYPE_MOBILE;
            } else if (type == ConnectivityManager.TYPE_WIFI) {
                return ConnectivityManager.TYPE_WIFI;
            }
        } catch (Exception e) {
            Log.e("NetworkStateUtils", e.toString());
        }
        return -2;
    }
}
